Conversation
|
This PR modifies |
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tests/rustdoc-ui/synthetic-auto-trait-impls/unconstrained-param-in-impl-ambiguity.stderr
Outdated
Show resolved
Hide resolved
tests/ui/associated-inherent-types/hr-do-not-blame-outlives-static-ice.stderr
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #150844) made this pull request unmergeable. Please resolve the merge conflicts. |
de845c2 to
1f5e308
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bbce6e5 to
06e17b4
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ns to determine if it makes sense to suggest adding the extra parameter to the generics of the struct on the impl ... for ...<> line
Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
`suggest_to_remove_or_use_generic` function Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
parameter to the impl struct and the struct definition if used in the impl body Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
1747f90 to
0b83de8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Signed-off-by: janwi_mac <jan.wilhelm77@gmail.com>
|
@rustbot ready |
| return self.span.shrink_to_hi(); | ||
| } | ||
|
|
||
| let is_impl_generic = |par: &&GenericParam<'_>| match par.kind { |
There was a problem hiding this comment.
| let is_impl_generic = |par: &&GenericParam<'_>| match par.kind { | |
| let is_param_explicit = |par: &&GenericParam<'_>| match par.kind { |
| let parameter_type = if is_lifetime { "lifetime" } else { "type" }; | ||
| if is_param_used { | ||
| let msg = format!( | ||
| "make use of the {} parameter `{}` in the `self` type", |
There was a problem hiding this comment.
| "make use of the {} parameter `{}` in the `self` type", | |
| "make use of the {} parameter `{}` in the `{}` type", |
Can you get the name of the Self type from its DefId?
| Applicability::MaybeIncorrect, | ||
| ); | ||
| if suggestions.len() == 2 { | ||
| let msg = format!("or make use of it"); |
There was a problem hiding this comment.
| let msg = format!("or make use of it"); | |
| let msg = format!("or use it"); |
| let msg2 = format!( | ||
| "and add it to the struct definition of {} as well since it's used in the body of the impl", | ||
| tcx.def_path_str(struct_def_id) | ||
| ); |
There was a problem hiding this comment.
You should probably use a MultiSpan with the definition and the impl and emit a single suggestion for this instead of two distinct suggestions but that would need to be applied together
There was a problem hiding this comment.
And change the message to "use this type parameter in the type definition"
| /// - `impl<'a> Struct { ... }` where `'a` is unused -> suggests removing `'a`. | ||
| /// - `impl<T> Struct { // T used in here }` where `T` is used in the body but not in the self type -> suggests adding `T` to the self type and struct definition. | ||
| /// - `impl<T> Struct { ... }` where the struct has a generic parameter with a default -> suggests adding `T` to the self type. | ||
| pub(crate) fn suggest_to_remove_or_use_generic( |
There was a problem hiding this comment.
Can you add your own test file that tests all of these cases specifically, as well as where the type is defined in another crate, or where the type is generated from a macro.
View all comments
This PR is an attempt to solve the issue described in the issue #107295